from django.contrib.auth.models import AbstractUser
from django.db import models

class User(AbstractUser):
    """自定义用户模型"""
    
    IDENTITY_CHOICES = [
        ('enterprise', '企业单位'),
        ('research', '科研院所'),
        ('government', '政府机关')
    ]

    email = models.EmailField('邮箱', unique=True)
    phone = models.CharField('手机号', max_length=11, unique=True)
    identity = models.CharField(
        '身份类型',
        max_length=20,
        choices=IDENTITY_CHOICES,
        default='enterprise'
    )
    created_at = models.DateTimeField('创建时间', auto_now_add=True)

    class Meta:
        db_table = 'users'
        verbose_name = '用户'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.username
